package xmltest;

import org.w3c.dom.Node;

import entity.general.Pair;

public class StringXMLConverter implements XMLConverter <String> {
	static String tagName = "String";
	
	public Pair <String, String> getObject(Node node)
	{
		if(!node.getNodeName().equals(tagName))
		{
			throw new XMLParseException(node.getNodeName() + " != " + tagName);
		}
		String text = node.getTextContent();
		String id = node.getAttributes().getNamedItem("id").getTextContent();
		return new Pair <String, String> (id, text);
	}
	
	public String toXML(String name, String object)
	{
		return "<String id='" + name + "'>" + name + "</String>\n";
	}
	
	public String getTagName()
	{
		return tagName;
	}
}
